import { typeUtils } from "@/utils";

/**DatePicker的通用配置 */
interface DatePickerCommonConf {
	/**可选的最大日期, 默认无限大 */
	maxDate?: Date;
	/**可选的最小日期, 默认无限小 */
	minDate?: Date;
}
/**DatePicker在type为Date时的配置 */
type DatePickerDateConf = typeUtils.Flatten<
	typeUtils.ObjectMerge<
		{ disabled?: boolean; clearable?: boolean },
		{
			/**日期选择器的类型, date或者rangedate, 默认为date */
			type?: "date" | "datetime";
			/**非范围选择时的占位内容 */
			placeholder?: string;
		} & DatePickerCommonConf
	>
>;

/**DatePicker在type为RageDate时的配置 */
type DatePickerRangeConf = typeUtils.Flatten<
	typeUtils.ObjectMerge<
		{ disabled?: boolean; clearable?: boolean },
		{
			/**日期选择器的类型, date或者rangedate, 默认为date */
			type: "daterange";
			/**范围选择时开始日期的占位内容 */
			startPlaceholder?: string;
			/**范围选择时结束日期的占位内容 */
			endPlaceholder?: string;
			/**选择范围时的分隔符, 默认为' / ' */
			rangeSeparator?: string;
		} & DatePickerCommonConf
	>
>;

/**DatePicker的总配置 */
type DatePickerConf = typeUtils.XOR<DatePickerDateConf, DatePickerRangeConf>;

/**DatePicker的data数据源的类型 */
type DatePickerDataType = number | [number, number];

export type {
	DatePickerCommonConf,
	DatePickerDateConf,
	DatePickerRangeConf,
	DatePickerConf,
	DatePickerDataType,
};
